package com.sunwayworld.basemodule.rm.hospital.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.hospital.dao.LimsHospitalInterfaceLogDao;
import com.sunwayworld.basemodule.rm.hospital.bean.LimsHospitalInterfaceLogBean;
import com.sunwayworld.basemodule.rm.hospital.service.LimsHospitalInterfaceLogService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsHospitalInterfaceLogServiceImpl implements LimsHospitalInterfaceLogService {

    @Autowired
    private LimsHospitalInterfaceLogDao limsHospitalInterfaceLogDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsHospitalInterfaceLogDao getDao() {
        return limsHospitalInterfaceLogDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsHospitalInterfaceLogBean limsHospitalInterfaceLog = jsonWrapper.parseUnique(LimsHospitalInterfaceLogBean.class);
        limsHospitalInterfaceLog.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsHospitalInterfaceLog);
        return limsHospitalInterfaceLog.getId();
    }

}
